package 曾世昌12_9.zuoye1;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.io.File;
import java.util.List;

public class dmeo {
    public static void main(String[] args) throws Exception {
        SAXReader saxReader = new SAXReader();
        Document read = saxReader.read( new File( "E:\\untitled5\\src\\mxdx3\\day6\\zuoye1\\city.xml" ) );
        Element root = read.getRootElement();
        List<Element> city = root.elements( "city" );
        for (Element element : city) {
            System.out.println("id："+element.attributeValue("id" ));
            System.out.println("cityname："+element.elementText( "cityname" ));
            System.out.println("cityarea：" +element.elementText( "cityarea" ));
            System.out.println("population："+element.elementText( "population" ));
        }
    }
}
